<script language="javascript">
function item_toggle(itemid, status) {
	document.itemToggle.item_id.value = itemid;
	document.itemToggle.item_status.value = status;
	document.itemToggle.list_id.value = <%= @list.id %>;
	document.itemToggle.submit();
}

</script>

<form name="itemToggle" action="/list/item_status" method="post">
<input type="hidden" name="item_id" value=""/>
<input type="hidden" name="item_status" value=""/>
<input type="hidden" name="list_id" value=""/>
</form>

<h2><%= link_to "<< Back to My Lists", :action => :index %></h2>
<div>
  <span><%= link_to "Edit", :action => :edit, :id => @list.id %></span>  |
  <span><%= link_to "Reorder", :action => :reorder, :id => @list.id %></span>  |
  <span><%= link_to "Delete", :action => :delete, :id => @list.id %></span>
</div>

<h2><%= @list.name %> <!-- (ID:<%= @list.id %>) --></h2>

<!-- all existing List Items for this list : -->
<h4>Existing Items <!--for List <%= @list.id %>-->:</h4>
<%if @list_items.length > 0 %>
  <ul class="list_items">
	<% for item in @list_items -%>
    <li><%= check_box('item_'+item.id.to_s, 'checked', {:onClick => "item_toggle(#{item.id}, 'f')"}, "deactivate", '') %> <%= item.content %></li>
  <% end %>
  </ul>
<% else %>
  There are no list items for this list.
<% end %>

<% form_for :add_items, :url => { :action => :add_list_item } do |form| %>
  <p>
    <%= form.text_field :content, :size => 40 %>
    <%= form.hidden_field :list_id, :value => @list.id %> 
  </p>
  <%= button_to "Add Item to '#{@list.name}'", :action => :add_list_item, :list_id => @list.id %>
<% end %>


<% if @inactive_items.length > 0 %>
	<ul class="completed_item">
		<% for inactive in @inactive_items -%>
		<li><%= check_box('item_'+inactive.id.to_s, 'checked', {:onClick => "item_toggle(#{inactive.id}, 't')"}, "reactivate", '') %> <%= inactive.content %></li>
		<% end %>
	</ul>
<% end %>


<% if flash[:notice] -%>
  <div id="notice"><%= flash[:notice] %></div>
<% end -%>

